<#include "/common/layout.html">
<@body>
<div class="content">
	<form class="form-horizontal" method="post" action="${request.contextPath}/system/role/doAdd" id="roleAddFrom" >
		<div class="box-body">
		<div class="form-group">
			<label class="col-sm-2 control-label">角色名</label>
			<div class="col-sm-10">
					<input type="text" name="roleName" class="form-control" placeholder="请输入角色名" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">描述</label>
			<div class="col-sm-10">
				<textarea class="form-control" name="roleDesc" rows="3" placeholder="请输入描述，最多300个字符 ..." required></textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">状态</label>
			<div class="col-sm-10">
				<label class="radio-box">
					<input name="roleState" type="radio" class="minimal" checked value="1"> 启用
				</label>
				<label class="radio-box">
					<input name="roleState" type="radio" class="minimal"  value="-1"> 禁用
				</label>
			</div>
		</div>
		</div>
	</form>
</div>
</@body>
<script type="text/javascript">
	function submitHandler() {
		if ($("#roleAddFrom").validate().form()) {
			var formData = $("#roleAddFrom").serialize();
			$.ajax({
				url : $("#roleAddFrom").attr('action'),
				type : 'POST',
				dataType: "json",
				data : formData,
				beforeSend : function() {
					$.modal.loading("正在处理中，请稍后...");
					$.modal.disable();
				},
				success : function(data) {
					if (data.code == 200) {
						if (data.msg) {
							parent.layer.msg(data.msg, {
								icon : 1
							});
						} else {
							parent.layer.msg('提交成功', {
								icon : 1
							});
						}
						parent.layer.closeAll('iframe'); // 关闭当前frame
						window.parent.data_oTable.draw(false);
					} else {
						layer.msg(data.msg, {
							icon : 2
						});
						$.modal.closeLoading();
						$.modal.enable();
					}
				}
			});
		}
	}
</script>